package model

import "gorm.io/gorm"

//文章信息
type Article struct {
	gorm.Model
	Articlename  string    `json:"article,omitempty" gorm:"type varchar(20)"`
	Category     *Category `json:"category,omitempty" gorm:"foreignkey:Categoryname;references:CategoryName"`
	Categoryname string    `json:"categoryname,omitempty"`
	Describe     string    `json:"describe,omitempty" gorm:"type varchar(100)"`
	Context      string    `json:"context,omitempty" gorm:"type longtext"`
	//hasmany  Aid映射id
	Comments []Comment `json:"comments,omitempty" gorm:"foreignkey:Aid"`
}

type Comment struct {
	gorm.Model
	//belongsto  references是参考的意思 意思就是references-->foreeignkey
	User         User   ` gorm:"foreignkey:CommentEmail;references:Email"`
	CommentEmail string `json:"commentemali" gorm:"not null"`
	Aid          uint   `json:"aid" gorm:"not null"`
	Context      string `json:"context" gorm:"type text"`
}
